﻿namespace CSharpPro._1002;

public class Narcissistic_number
{
    //输出1000以内的水仙花数，使用for循环实现
    public static void print()
    {
        Console.WriteLine("1000以内的水仙花数有：");
        //个位数的水仙花数
        Console.Write("1 2 3 4 5 6 7 8 9 ");
        for (int i = 10; i < 100; i++)
        {
            int a = i / 10;
            int b = i % 10;
            int c = a * a + b * b;
            if (c == i)
            {
                Console.Write(i + " ");
            }
        }
        for (int i = 100; i < 1000; i++)
        {
            int a = i / 100;
            int b = i % 100 / 10;
            int c = i % 10;
            int d = a * a * a + b * b * b + c * c * c;
            if (d == i)
            {
                Console.Write(i + " ");
            }
        }
       

    }
}